<!-- daterange picker -->
<link rel="stylesheet" href="__PUBLIC__/AdminLTE/plugins/daterangepicker/daterangepicker.css">
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            客户统计列表
        </h1>
        <ol class="breadcrumb">
            <li><a href="/admin"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li class="active">客户管理</li>
            <li class="active">客户统计列表</li>
        </ol>
    </section>
    <section class="content">
        <div class="box">
            <div class="box-header with-border">
                <form class="form-inline" action="/admin/stat/yzStatCustomerList" method="get">
                    <if condition="$user_group_id eq 0">
                        <div class="form-group">
                            <label for="type">类别 </label>
                            <select class="form-control" name="type" id="type">
                                <option value="0">请选择</option>
                                <foreach name="typeList" item="type_val" key="key">
                                    <option value="{$key}" <if condition="$key eq $type">selected</if>>{$type_val}</option>
                                </foreach>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="company_name">公司名称 </label>
                            <input type="text" class="form-control" id="company_name" name="company_name" placeholder="输入公司名" value="{$company_name}">
                        </div>
                        <div class="form-group">
                            <label for="department_id">部门 </label>
                            <select class="form-control" name="department_id" id="department_id">
                                <option value="0">请选择</option>
                                <foreach name="departmentList" item="department">
                                    <option value="{$department.id}" <if condition="$department.id eq $department_id">selected</if>>{$department.name}</option>
                                </foreach>
                            </select>
                        </div>
                        <div class="form-group">
                            <label for="admin_name">部门人员 </label>
                            <input type="text" class="form-control" id="admin_name" name="admin_name" placeholder="录入人" value="{$admin_name}">
                        </div>
                        <div class="form-group">
                            <label for="product_name">推广产品 </label>
                            <input type="text" class="form-control" id="product_name" name="product_name" placeholder="推广产品" value="{$product_name}">
                        </div>
                        <div class="form-group">
                            <label>日期</label>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <i class="fa fa-calendar"></i>
                                </div>
                                <input type="text" class="form-control pull-right" name="search_time" id="reservation" value="{$search_time}">
                            </div>
                            <!-- /.input group -->
                        </div>
                        <button type="submit" class="btn btn-info" id="save-btn">查询</button>&nbsp;
                    </if>
                </form>
            </div>
            <div class="box-body">
                <table class="table table-bordered">
                    <tbody>
                    <tr>
                        <th style="width: 40px">ID</th>
                        <th>类别</th>
                        <th>公司名称</th>
                        <th>订单数</th>
                        <th>最近合作</th>
                        <th style="width: 180px">操作</th>
                    </tr>
                    <if condition="count($customerList) eq 0"><tr><td class="text-center" colspan="12">暂无数据...</td></tr></if>
                    <foreach name="customerList" item="customer">
                            <tr>
                                <td>{$customer.id}</td>
                                <td>{$typeList[$customer['type']]}</td>
                                <td>{$customer.company_name}</td>
                                <td>{$customer.order_sum}</td>
                                <td>{$customer.order_time}</td>
                                <td>
                                    <button class="btn btn-primary btn-xs" type="button" onclick="window.location.href='/admin/stat/yzStatCustomerOrderList?company_name={$customer.company_name}'">详情</button>&nbsp;
                                </td>
                            </tr>
                        </foreach>
                    </tbody>
                </table>
            </div>
            <div class="box-footer clearfix">{$page_html}</div>
        </div>
    </section>
</div>
<!-- date-range-picker -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
<script src="__PUBLIC__/AdminLTE/plugins/daterangepicker/daterangepicker.js"></script>
<script type="application/javascript">
    $(function () {
        //Date range picker
        $('#reservation').daterangepicker({
            autoUpdateInput: false,
            applyClass : 'btn-sm btn-success',
            cancelClass : 'btn-sm btn-default',
            locale: {
                applyLabel: '确认',
                cancelLabel: '取消',
                fromLabel : '起始时间',
                toLabel : '结束时间',
                customRangeLabel : '自定义',
                weekLabel: 'W',
                daysOfWeek:['日','一','二','三','四','五','六'],
                monthNames:['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
                firstDay : 1
            },
            startDate: new Date(),
            endDate: new Date(),
            ranges: {
                '今天': [moment(), moment()],
                '昨天': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                '最近7天': [moment().subtract(6, 'days'), moment()],
                '最近30天': [moment().subtract(29, 'days'), moment()],
                '本月': [moment().startOf('month'), moment().endOf('month')],
                '上个月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
            }
        });
        $('#reservation').on('apply.daterangepicker', function(ev, picker) {
            $(this).val(picker.startDate.format('MM/DD/YYYY') + ' - ' + picker.endDate.format('MM/DD/YYYY'));
        });
        $('#reservation').on('cancel.daterangepicker', function(ev, picker) {
            $(this).val('');
        });
    });
</script>